package com.ego.product.controller;

import java.util.Arrays;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.ego.product.po.SpuComment;
import com.ego.product.service.SpuCommentService;
import com.ego.common.util.Result;

/**
 * @program: ego
 * @description 商品评价控制器
 * @author KamTang
 * @date 2022-11-13 12:56:14
 */
@RestController
@RequestMapping("product/spucomment")
public class SpuCommentController {

    @Autowired
    private SpuCommentService spuCommentService;

    /**
     * 信息
     */
    @GetMapping("/get/{id}")
    public Result get(@PathVariable("id") Long id){
		SpuComment spuComment = spuCommentService.getById(id);
        return Result.ok().put("spuComment", spuComment);
    }

    /**
     * 保存
     */
    @PostMapping("/save")
    public Result save(@RequestBody SpuComment spuComment){
		spuCommentService.save(spuComment);
        return Result.ok();
    }

    /**
     * 修改
     */
    @PostMapping("/update")
    public Result update(@RequestBody SpuComment spuComment){
		spuCommentService.updateById(spuComment);
        return Result.ok();
    }

    /**
     * 删除
     */
    @PostMapping("/delete")
    public Result delete(@RequestBody Long[] ids){
		spuCommentService.removeByIds(Arrays.asList(ids));
        return Result.ok();
    }

}
